home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / Programs / Ipswitch.IMail.Server.Pro.8.0.Winall / IMail8ec.exe / data1.cab / Web_Standard / Cookie.cgi < prev    next >
Encoding:
Text File  |  2003-05-07  |  1.3 KB  |  59 lines

  1.     function getCookie(name)
  2.     {
  3.         var cookieFound = false;
  4.         var start = 0;
  5.         var end = 0;
  6.         var cookieString = document.cookie;
  7.         var cookieValue;
  8.  
  9.         var i = 0;
  10.         
  11.         //scan the Cookie for the name
  12.         while (i <= cookieString.length){
  13.             start = i;
  14.             end = start + name.length;
  15.             if(cookieString.substring(start, end) == name){
  16.                 cookieFound = true;
  17.                 break;
  18.             }
  19.             i++;
  20.         }
  21.         
  22.         //is name found/
  23.         if(cookieFound){
  24.             start = end+1;
  25.             end = document.cookie.indexOf(";",start);
  26.             if(end < start)
  27.                 end = document.cookie.length;
  28.             cookieValue = document.cookie.substring(start, end);
  29.             start = 0;
  30.             end = cookieValue.indexOf(" ", start);
  31.             if(end < start)
  32.                 end = cookieValue.length;
  33.             return cookieValue.substring(start, end);
  34.         }
  35.         return "";
  36.     }
  37.  
  38.     function initFields()
  39.     {
  40.         document.logon.userid.value = getCookie("IMail_UserId");
  41.         document.logon.passwd.value = getCookie("IMail_password");
  42.     }
  43.  
  44.     function deleteCookie(name, path, domain){
  45.         if(getCookie(name)){
  46.             document.cookie = name+ "=" + 
  47.                 ((path) ? "; path=" + path : "") +
  48.                 ((domain) ? "; domain=" + domain: "") +
  49.                 "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  50.         }
  51.     }
  52.  
  53.     function formSubmit()
  54.     {
  55.         deleteCookie("IMail_UserId", "/", null);
  56.         deleteCookie("IMail_password", "/", null);
  57.         deleteCookie("IMail_UserKey", "/", null);
  58.     }
  59.